import {
    httpAction,
    getAction
} from '@/http/axios.js';
import E from 'wangeditor';
export const JVxeTableModelMixin = {
    data() {
        return {
            title: '操作',
            visible: false,
            confirmLoading: false,
            scrolling: true,
            ruleForm: {},
            uploadfileurl: this.$url.baseURL + '/upload/uploadfile',
        }
    },
    methods: {
        submitForm() {
            var arr = this.$refs.tree.getCheckedKeys();
            var halfarr = this.$refs.tree.getHalfCheckedKeys();
            halfarr.forEach((item, index) => {
                arr.push(item)
            })

            this.$confirm('确认保存吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let url = this.url.edit
                httpAction(url,{
                    roleid: this.ruleForm.id,
                    permissionStr: arr.toString()
                }).then(resp => {
                    if (resp.code != 0) {
                        this.$message.error(resp.msg);
                    } else {
                        this.$message({
                            type: 'success',
                            message: '已保存'
                        });
                        this.$emit('ok')
                    }
                })
            }).catch(() => {
            });
        },
        //清空数据
        resetForm() {
            this.$refs['ruleForm'].resetFields();
        },
        /** 当点击了编辑（修改）按钮时调用此方法 */
        edit(record) {
            console.log(record);
            this.visible = true
            this.ruleForm = Object.assign({}, record)
        },

        /** 关闭按钮点击事件 */
        handleCancel() {
            this.visible = false
            this.$emit('close')
        },

    }
}
